import axios from 'axios'

const api = axios.create({
    baseURL: 'http://113.31.110.212:4000'
})

export { api, axios }

export function getAllPalylists() {
    return api.get('/playlist/catlist')
}
export function getPlaylistDetail(cate) {
    return api.get(`/top/playlist?cat=${cate}`)
}

export function getPlaylistDetailById(id) {
    return api.get(`/playlist/detail?id=${id}`)
}

export function getMusicUrl(id) {
    return api.get(`/song/url?id=${id}`)
}

export function addToPlaylist(payload) {
    return axios({
        url: `http://127.0.0.1:8000/add_collection`,
        method: 'GET',
        params: payload
    })
}
export function getPlayListById(user_id) {
    return axios({
        url: 'http://localhost:8000/get_collection?user_id=' + user_id,
        method: "GET"
    })
}
export function getRecList(user_id) {
    return api.get('/recommend/songs')
}

export function getRecSongs(user_id) {
    return axios({
        url: 'http://localhost:8000/get_rec?user_id=' + user_id,
        method: 'GET'
    })
}
export function loginUser(payload) {
    return axios({
        url: 'http://localhost:8000/login',
        method: 'GET',
        params: payload
    })
}

export function registerUser(payload) {
    return axios({
        url: 'http://localhost:8000/register',
        method: 'GET',
        params: payload
    })
}

export function removePlaylist(payload) {
    return axios({
        url: 'http://localhost:8000/delete_collection',
        method: 'GET',
        params: payload
    })
}

export function getSongDetails(song_id) {
    return axios({
        url: 'http://localhost:8000/get_song?song_id=' + song_id,
        method: 'GET',
    })
}